package org.xlh.springboot.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class SystemService {
    @Value("${myapp.username}")
    private String username;

    @Value("${myapp.age}")
    private Integer age;

    @Value("${myapp.email}")
    private String email;

    //当使用@Value注解时，如果这个key不存在，并且没有指定默认值，则会抛出异常。
    @Value("${myapp.password:123456}")
    private String password;

    public void printInfo(){
        System.out.println(username);
        System.out.println(age);
        System.out.println(email);
        System.out.println(password);
    }
}
